package engine;



public class Card {
	
	private final static String[] suits = {"Clubs", "Spades", "Hearts", "Diamonds"};
	
	private final static String[] ranks = {"2", "3", "4", "5", "6", "7", "8", "9", "T", "Jack", "Queen", "King", "Ace"};
	
	private final String rank;
	
	private final String suit;

	private final String image;
	
	Card(int suit, int rank) {
		if (((rank >= 0) && (rank < ranks.length)) && ((suit >= 0) && (suit < suits.length))) {
			this.rank = ranks[rank];
			this.suit = suits[suit];
		}
		else {
			this.rank = "";
			this.suit = "";
		}
		this.image = "./img/cards/"+this.rank.charAt(0)+this.suit.charAt(0)+".png";
	}
	
	public static int getNrOfRanks() {
		return ranks.length;
	}
	
	public static int getNrOfSuits() {
		return suits.length;
	}
	
	public static String getRank(int i) {
		return ranks[i];
	}
	
	public String getRank() {
		return this.rank;
	}
	
	public String getSuit() {
		return this.suit;
	}
	
	public String getCardName() {
		return (this.getRank() + " of " + this.getSuit());
	}
	
	public int getValue() {
		int index = -1;
		
		for (int i = 0; i < getNrOfRanks(); i++) {
			if (getRank().equals(ranks[i])) {
				index = i + 2;
				break;
			}
		}
		
		return index;
	}
}
